<style type="text/css" media="screen">
.my-uploadify-button {
    background:none;
    border: none;
    text-shadow: none;
    border-radius:0;
}

.uploadify:hover .my-uploadify-button {
    background:none;
    border: none;
}

.fileQueue {
    width: 550px;
    height: 88px;
    overflow: auto;
    border-style: solid;
    border-width: 1px 0 0 0;
    border-color: #E5E5E5;
}

#fileupload
{
margin-bottom: 5px;
}

.resQuery span.error {
    position: absolute !important;
    left: 260px;
}

</style>

<div class="pageContent">
    <form method="post"
        action="${rc.getContextPath()}/manage/maintainConfig/saveMaintainConfig"
        class="pageForm required-validate"
        onsubmit="return validateCallback(this, subDone);">
        <div class="pageFormContent">
            <input type="hidden" name="navTabId" value="${navTabId!''}">
            <input type="hidden" name="id"
                value="<#if (config.equipmentCode)??>${config.equipmentCode!''}</#if>">
                <input type="hidden" id="fileJson">
            <fieldset class="dataset">
                <dl>
                    <dt><@label key="equipmentCode.C,colon">设备编号：</@label></dt>
                    <dd class="resQuery">
                      <input readonly value="<#if (config.equipmentCode)??>${config.equipmentCode!''}</#if>" class="required" id="equipmentLookup.equipmentCode" name="equipmentCode" type="text"/>
                    
                    </dd>
                </dl>
                <dl>
                    <dt><@label key='equipmentText.C,colon'>设备描述：</@label></dt>
                <dd><input value="<#if (config.equipmentText)??>${config.equipmentText!''}</#if>" id="equipmentLookup.equipmentText" readonly size="22" type="text" maxlength="60" name="equipmentText" />
            </dd>
                </dl>
                <dl>
                    <dt><@label key="strategyCode.C,colon">维护策略编号：</@label></dt>
                    <dd>
                      <input readonly class="required" id="strategyLookup.strategyCode" name="strategyCode" type="text" value="<#if (config.strategyCode)??>${config.strategyCode!''}</#if>" />
                    </dd>
                </dl>
                    <dl>
                    <dt><@label key="strategyText.C,colon">维护策略描述：</@label></dt>
                    <dd>
                        <input readonly id="strategyLookup.strategyText" name="strategyText"
                            size="32" type="text" value="<#if (config.strategyText)??>${config.strategyText!''}</#if>"/>
                    </dd>
                </dl>
                    <dl>
                    <dt><@label key="prevMaintainDate.C,colon">上次维护日期：</@label></dt>
                    <dd class="resQuery">
                        <input type="text" class="required date"  readonly="readonly" name="prevMaintainDate" dateFmt="yyyy-MM-dd" value="<#if (config.prevMaintainDate)??>${config.prevMaintainDate?string("yyyy-MM-dd")}</#if>"/> <a class="inputDateButton" href="javascript:;"><@label key="select.B">选择</@label></a>
                    </dd>
                </dl>
                                <dl>
                    <dt><@label key="nextMaintainDate.C,colon">下次维护日期：</@label></dt>
                    <dd>
                        <input type="text" readonly="readonly" name="nextMaintainDate" dateFmt="yyyy-MM-dd" value="<#if (config.nextMaintainDate)??>${config.nextMaintainDate?string("yyyy-MM-dd")}</#if>"/>
                    </dd>
                </dl>
                                <dl>
                    <dt><@label key="currCountValue.C,colon">当前损耗点：</@label></dt>
                    <dd>
                        <input type="text" class="required digits" name="currCountValue"  maxlength="10" value="<#if (config.currCountValue)??>${config.currCountValue!''}</#if>"/>
                    </dd>
                </dl>
                    <dl>
                    <dt><@label key="totalCountValue.C,colon">累计损耗点：</@label></dt>
                    <dd>
                        <input type="text" readonly class="required digits" name="totalCountValue"  maxlength="10" value="<#if (config.totalCountValue)??>${config.totalCountValue!''}</#if>"/>
                    </dd>
                </dl>
                <dl style="height:150px;width:570px">
                <dd>
                <fieldset style="border: 1px solid #E5E5E5;padding: 5px;">
                 <legend style="border:none"><@label key="uploadList.C">待上传列表</@label></legend>
                <input id="fileupload" type="file" 
            uploaderOption="{
            swf:'${rc.getContextPath()}/manage/styles/uploadify/scripts/uploadify.swf',
            uploader:'${rc.getContextPath()}/manage/maintainConfig/saveAttachment;jsessionid=${sessionid}',
            fileTypeDesc: 'All Files',
            fileTypeExts: '*.*',  
            queueID:'fileQueue',
            buttonClass:'my-uploadify',
            width:61,
            height:24,
            buttonText:'<@label key='chooseFile.C'>选择文件</@label>', 
            auto:false,
            multi:true,
            simUploadLimit:10,
            onQueueComplete:onUploadSuccess
        }"
    />
        <div id="fileQueue" class="fileQueue"></div>
        </fieldset>
        <dd>
                </dl>
                <dl style="padding:0;height:120px;width:560px;border-color: #d8dfe5; border-style: solid;border-width: 1px;">
                <table class="table" layoutH="440" width="100%" id="processAttachMentTable">
                            <thead>
                                <tr>
                                    <th width="100px"><@label key='fileName.C'>文件名称</@label></th>
                                    <th width="100px"><@label key='fileSize.C'>文件大小(bytes)</@label></th>
                                    <th width="50px"><@label key="opera.C">操作</@label></th>
                                </tr>
                            </thead>
                            <tbody>
                                <#if files??><#if (files?size>0)> <#list files as file>
                                            <tr id="${file.id!''}" target="file_id" rel="${file.fileName!''}">
                                                <td width="100">${file.fileName!''}</td>
                                                <td width="100">${file.fileSize!''}</td>
                                                <td width="100">
                                                <a title="<@label key='delete.B'>删除</@label>"style="cursor:pointer" target="ajax" class='btnDel' onclick="_delProcessAttachment('${file.equipmentCode!''}','${file.strategyCode!''}','${file.attachmentCode!''}','${file.id!''}');"></a>
                                                <a class='btnAttach' href="${rc.getContextPath()}/manage/common/downloadAttachement?fileName=${file.fileName!''}&attachmentCode=${file.attachmentCode!''}"></a>
                                                </td>
                                            </tr>
                                </#list> </#if> </#if>
                            </tbody>
                        </table>
                </dl>
            </fieldset>
        </div>
            <#assign createInfo=config/>
            <#include "/common/createInfo.html">
        <div class="formBar">
            <ul>
                <li><div class="buttonActive">
                        <div class="buttonContent">
                            <button type="submit"><@label key="save.B">保存</@label></button>
                        </div>
                    </div>
                </li>
                <li>
                    <div class="buttonActiveGrey">
                        <div class="buttonContent">
                            <button type="button" class="close"><@label key="cancel.B">取消</@label></button>
                        </div>
                    </div></li>
            </ul>
        </div>
    </form>
</div>
<script type="text/javascript">
    function subDone(json)
    {
        if(json["statusCode"]==200)
            {
            if($("#fileQueue",$.pdialog.getCurrent()).text()!="")
                {
                var equipmentCode = $("#equipmentLookup\\.equipmentCode",$.pdialog.getCurrent()).val();
                var strategyCode = $("#strategyLookup\\.strategyCode",$.pdialog.getCurrent()).val();
                $("#fileJson",$.pdialog.getCurrent()).val(JSON.stringify(json));
                $('#fileupload',$.pdialog.getCurrent()).uploadify('settings','formData',{'equipmentCode': equipmentCode,'strategyCode':strategyCode});
                $('#fileupload',$.pdialog.getCurrent()).uploadify('upload', '*');
                }
            else
                {
                dialogAjaxDone(json);
                }
    
            }
        else
            {
            dialogAjaxDone(json);
            }
        
      
    }
    
    function onUploadSuccess()
    {
        dialogAjaxDone(jQuery.parseJSON($("#fileJson",$.pdialog.getCurrent()).val()));
    }
    
    function _delProcessAttachment(equipmentCode,strategyCode,attachmentCode,id) {
        alertMsg.confirm("<@label key='confirmDelAttachment.M'>确定删除此附件吗?</@label>", {
            okCall : function() {
                $.DWZajax({
                    url:hostUrl +"/maintainConfig/delConfigAttachment",
                    data:{'equipmentCode':equipmentCode,'strategyCode':strategyCode,'attachmentCode':attachmentCode,'id':id},
                    callback:function(data){
                        var _id =id;
                        $("tr#"+_id,$.pdialog.getCurrent()).remove();
                    }
                });
            }
        });
        
        
    }
    </script>